Aspose html to pdf with header footer


#21

@nipunjainindia

You used the wrong API for HTML to PDF conversion. You should use the following API to convert HTML to PDF:

PUT /html/convert/pdf.

With the above API, PDF document looks as follows: Sample_Html.pdf.

There is still an alignment issue, apparently, it is because font-family used in PDF document is different from font-family in HTML document. In order to fix this issue, we may need to upload the missing font to our Production server. We are investigating this issue HTMLCLOUD-630 in detail and will share our findings soon.


#22

@nipunjainindia

Following is an API example to update Font, Color, Size and Case of text in Header/Footer of a Word document:

POST /words/{name}/{paragraphPath}/runs/{index}/font

name = MyDocument_R.docx
fontDto = {
“AllCaps”: true,
“Bold”: true,
“Color”: { “Web”: “#1000ff” },
“Name”: “Verdana”,
“Size”: 14
}
paragraphPath = sections/0/headersfooters/0/paragraphs/0
index = 0
destFileName = MyDocument_F.docx

Input Document: MyDocument_R.docx
Output Document: MyDocument_F.docx


#23

@nipunjainindia

Not able to set the size/position/alignment of the image

With attributes Width and Height of drawingObject you can set the size of an Image. By setting Width and Height value to 50, you can reduce the image size by half as shown in the following example:

PUT /words/{name}/{nodePath}/drawingObjects

name = MyDocument_F.docx
drawingObject = { “Left”: 0, “Width”: 50, “Height”: 50 }
imageFile = environment.png
destFileName = MyDocument_D.docx
nodePath = sections/0/headersfooters/0/paragraphs/0

Default values of Width and Height attributes are 100.

Input Document: MyDocument_F.docx
Output Document: MyDocument_D.docx


#24

Guys, We again followed all your recommendations but the result is not satisfactory. This has now become a make or break situation for us.I am sharing with you now all the resulting files along with the screenshots of API calls thru swagger interface.

Please go through them carefully and let us know what mistake are we doing as there are still many issues in the converted files.

Conversion : html --> pdf
API used : https://apireference.aspose.cloud/html/#!/Conversion/Conversion_PutConvertDocumentInRequestToPdf
Input file : comprehensive_report.zip (7.6 KB)

Parameter Values : image.png (34.3 KB)
Resulting Doc: report (3).pdf (108.9 KB)
Issues :

  • Unwanted page breaks
  • Html not top aligned in case of position and content (e.g. section 2 : question 2.1 )
  • page margins (top/bottom) are not consistent across pages

Conversion : PDF–> word
API used : https://apireference.aspose.cloud/pdf/#!/Convert/PutPdfInStorageToDoc
Input file : report (3).pdf (108.9 KB)
Parameter Values : image.png (30.9 KB)

Resulting Doc: report.zip (109.5 KB)

Issues :

  • Unwanted page breaks
  • Html not top aligned in case of position and content (e.g. section 2 : question 2.1 )
  • page margins (top/bottom) are not consistent across pages

Conversion : word–> word + header + text + logo + font dto
API used :
https://apireference.aspose.cloud/words/#!/HeadersFooters/PutHeaderFooter
https://apireference.aspose.cloud/words/#!/Runs/PutRun
https://apireference.aspose.cloud/words/#!/WordsSections/UpdateSectionPageSetup
https://apireference.aspose.cloud/words/#!/DrawingObjects/PutDrawingObject
https://apireference.aspose.cloud/words/#!/Runs/PostDocumentParagraphRunFont

Input file : the word doc created above
Parameter Values : image.png (35.5 KB)
image.png (38.3 KB)
image.png (38.3 KB)
image.png (38.6 KB)
image.png (39.2 KB)

Resulting Doc: report-withHeaderTextlogoFont (4).zip (45.8 KB)

Issues :

  • Header and Section title overlapping each other
  • Not able to align text in header footer
  • Not able to align image in header
  • Not able to set page margins
  • And rest of the above issues are still coming

Guys, Please let us know if we can anyhow help you understand our requirements and problems we are going through other than this medium. we need to take a decision in coming days. Please be comprehensive about your recommendations and help us in achieving the desired result at the earliest.

Thanks
Awaiting your response

p.s. : I am attaching this folder which contains all the files (sample, intermediaries and final outcome)

files.zip (398.0 KB)


#25

@abhisheknagarro

Conversion: html --> pdf
Issues:

  1. Unwanted page breaks
  2. Html not top aligned in case of position and content (e.g. section 2 : question 2.1 )
  3. page margins (top/bottom) are not consistent across pages

We are able to replicate the same issues on our end too. The issue is logged in our internal tracking software (HTMLCLOUD-630) and we are working hard to fix it at the earliest.

  • Not able to align text in header footer
  • Not able to align image in header

Unfortunately, at present, with Aspose.Words APIs you cannot align text and image in Header/Footer. The feature request has been logged in our tracking software as WORDSCLOUD-552 and we will update you here as soon as the requested feature is implemented.

We are sorry for the inconvenience caused.


#26

Hi Team,

As you already know, We have been evaluating your product for the file conversions we need for our business.

Primarily, HTML -> WORD and then eventually from WORD -> PDF, However as communicated earlier by one of your team member that HTML -> WORD is not possible directly and we may need to take a different route to achieve the same (HTML -> PDF -> WORD). Please refer
image.png (18.8 KB)

However, During our evaluation we have found that there are APIs available to get a html -> word and also put objects as part of header/footer.

https://apireference.aspose.cloud/words/#!/Convert/PutConvertDocument to convert HTML -> WORD.

So, Can you please clear this to us if you officially support these APIs and they are production ready?

Regards,
Nipun Jain


#27

Hi Team,

Any updates.

Regards,
Nipun Jain


#28

@nipunjainindia

However, During our evaluation we have found that there are APIs available to get a html -> word

Yes, we have an API to convert HTML to Word https://apireference.aspose.cloud/words/#!/Convert/PutConvertDocument

However as communicated earlier by one of your team member that HTML -> WORD is not possible directly

I apologize for providing incorrect information earlier. I answered the query by just considering Aspose.HTML APIs which only provide API for HTML to PDF conversion. I forgot to mention that Aspose.Words provides an API to convert HTML to Word. In fact Aspose.Words provides an HtmlSaveOptions object which gives number of options for HTML to Word conversion:

< HtmlSaveOptions >
<!-- common part -->
< SaveFormat >{string}</ SaveFormat >
< FileName >{string}</ FileName >
<!-- specific part -->
< PrettyFormat >{true/false}</ PrettyFormat > <!-- default value = false -->
< AllowNegativeIndent >{true/false}</ AllowNegativeIndent > <!-- default value = false -->
< CssStyleSheetFileName >{string}</ CssStyleSheetFileName > <!-- default value = "" -->
< CssStyleSheetType >{Embedded/External/Inline}</ CssStyleSheetType > <!-- default value = Inline -->
< DocumentSplitCriteria >{ColumnBreak/HeadingParagraph/None/PageBreak/SectionBreak}</ DocumentSplitCriteria > <!-- default value = None -->
< DocumentSplitHeadingLevel >{number}</ DocumentSplitHeadingLevel > <!-- default value = 2 -->
< Encoding >{string}</ Encoding > <!-- default value = "UTF-8" -->
< ExportDocumentProperties >{true/false}</ ExportDocumentProperties > <!-- default value = false -->
< ExportFontsAsBase64 >{true/false}</ ExportFontsAsBase64 > <!-- default value = false -->
< ExportFontResources >{true/false}</ ExportFontResources > <!-- default value = false -->
< ExportHeadersFootersMode >{FirstSectionHeaderLastSectionFooter/None/PerSection}</ ExportHeadersFootersMode > <!-- default value = PerSection -->
< ExportImagesAsBase64 >{true/false}</ ExportImagesAsBase64 > <!-- default value = false -->
< ExportLanguageInformation >{true/false}</ ExportLanguageInformation > <!-- default value = false -->
< ExportListLabels >{Auto/AsInlineText/ByHtmlTags}</ ExportListLabels > <!-- default value = Auto -->
< ExportMetafileAsRaster >{true/false}</ ExportMetafileAsRaster > <!-- default value = true -->
< ExportOriginalUrlForLinkedImages >{true/false}</ ExportOriginalUrlForLinkedImages > <!-- default value = false-->
< ExportPageSetup >{true/false}</ ExportPageSetup > <!-- default value = false -->
< ExportPageMargins >{true/false}</ ExportPageMargins > <!-- default value = false -->
< ExportRelativeFontSize >{true/false}</ ExportRelativeFontSize > <!-- default value = false -->
< ExportRoundtripInformation >{true/false}</ ExportRoundtripInformation > <!-- default value = true -->
< ExportTextBoxAsSvg >{true/false}</ ExportTextBoxAsSvg > <!-- default value = false -->
< ExportTextInputFormFieldAsText >{true/false}</ ExportTextInputFormFieldAsText > <!-- default value = false -->
< ExportTocPageNumbers >{true/false}</ ExportTocPageNumbers > <!-- default value = false -->
< ExportXhtmlTransitional >{true/false}</ ExportXhtmlTransitional > <!-- default value = false -->
< FontResourcesSubsettingSizeThreshold >{number}</ FontResourcesSubsettingSizeThreshold > <!-- default value = 0 -->
< FontsFolder >{string}</ FontsFolder > <!-- default value = "" -->
< FontsFolderAlias >{string}</ FontsFolderAlias > <!-- default value = "" -->
< HtmlVersion >{Xhtml| Html5}</ HtmlVersion > <!-- default value = "Xhtml" -->
< ImageResolution >{number}</ ImageResolution > <!-- default value = 96 -->
< ImagesFolder >{string}</ ImagesFolder > <!-- default value = "" -->
< ImagesFolderAlias >{string}</ ImagesFolderAlias > <!-- default value = "" -->
< OfficeMathOutputMode >{Image/MathML/Text}</ OfficeMathOutputMode > <!-- default value = Image -->
< ResourceFolder >{string}</ ResourceFolder > <!-- default is an empty string -->
< ResourceFolderAlias >{string}</ ResourceFolderAlias > <!-- default is an empty string -->
< ScaleImageToShapeSize >{true/false}</ ScaleImageToShapeSize > <!-- default value = true -->
< TableWidthOutputMode >{All/None/RelativeOnly}</ TableWidthOutputMode > <!-- default value = All -->
< ExportDropDownFormFieldAsText >{true/false}</ ExportDropDownFormFieldAsText > <!-- default value = false -->
</ HtmlSaveOptions >

So, Can you please clear this to us if you officially support these APIs and they are production ready?

Yes, our APIs are production ready and we have a very strong customer base using these APIs.