We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Convert PDF to HTML using Aspose.PDF for .NET - empty spaces in output and margin issue

hi. when i upload PDF file and try to make it HTML,
i get empty spaces,

i give you the code and the file

 if lcase(fileType)="pdf" then
                    Dim docNewSteam As New MemoryStream()
				              Dim docHtmla As New Aspose.pdf.Document(htmlStream)

                    Dim doc As  new  Aspose.Pdf.Document(htmlStream)
                    Dim htmlOptions As  new Aspose.Pdf.HtmlSaveOptions()
                    
                    ' init MarginPartStyle with margin in 20 points
                    Dim commonMargin As New Aspose.Pdf.SaveOptions.MarginPartStyle(20)
                    ' init MarginPartStyle with margin value auto
                    Dim autoMargin As New Aspose.Pdf.SaveOptions.MarginPartStyle(true)
                    ' set commonMargin to every page side
                    htmlOptions.PageMarginIfAny = new Aspose.Pdf.HtmlSaveOptions.MarginInfo(commonMargin)
                    
                    'set horizontal page align to center
                    htmlOptions.PageMarginIfAny.LeftMarginIfAny = autoMargin
                    htmlOptions.PageMarginIfAny.RightMarginIfAny = autoMargin
                    
                    htmlOptions.PartsEmbeddingMode = Aspose.Pdf.HtmlSaveOptions.PartsEmbeddingModes.EmbedAllIntoHtml
                    htmlOptions.LettersPositioningMethod = 0 '//LettersPositioningMethods.UseEmUnitsAndCompensationOfRoundingErrorsInCss
                    htmlOptions.RasterImagesSavingMode = Aspose.Pdf.HtmlSaveOptions.RasterImagesSavingModes.AsEmbeddedPartsOfPngPageBackground
                   '' htmlOptions.PreventGlyphsGrouping = True
                   '' htmlOptions.SimpleTextboxModeGrouping = True
                    htmlOptions.BatchSize = 640
                    doc.Save(docNewSteam, htmlOptions)
                    
                    
                    
                    Dim PageInfo As New PageInfo()
                    doc.PageInfo.Width  = 640
                

                    
                  Dim htmlPdfReader As New StreamReader(docNewSteam, Encoding.GetEncoding(65001))
                  docNewSteam.Seek(0, SeekOrigin.Begin)
                  htmlCv = htmlPdfReader.ReadToEnd()
                  htmlPdfReader.Close()

sarit.pdf (166.7 KB)

@eranlipi

We were unable to notice any issue with output HTML while testing the scenario with Aspose.PDF for .NET 20.4. For your kind reference, an output HTML is also attached. Would you please make sure to use latest version and in case you still face any issue, please feel free to let us know.

sarit_out.zip (178.9 KB)

@asad.ali

i mean that when i try to change the margin. i don’t see any change

 ' init MarginPartStyle with margin in 20 points
                Dim commonMargin As New Aspose.Pdf.SaveOptions.MarginPartStyle(20)
                ' init MarginPartStyle with margin value auto
                Dim autoMargin As New Aspose.Pdf.SaveOptions.MarginPartStyle(true)
                ' set commonMargin to every page side
                htmlOptions.PageMarginIfAny = new Aspose.Pdf.HtmlSaveOptions.MarginInfo(commonMargin)
                
                'set horizontal page align to center
                htmlOptions.PageMarginIfAny.LeftMarginIfAny = autoMargin
                htmlOptions.PageMarginIfAny.RightMarginIfAny = autoMargin

@eranlipi

We were able to notice that left and right margins were not effected after trying different values in points. Hence, have logged an issue as PDFNET-48009 in our issue tracking system. We will further look into its details and keep you posted with the status of its correction. Please be patient and spare us some time.

We are sorry for the inconvenience.

The issues you have found earlier (filed as PDFNET-48009) have been fixed in Aspose.PDF for .NET 20.6.

1 Like