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

Free Support Forum - aspose.com

Aspose PDF New Line error

We are using Aspose JAVA PDF 17.12 Version to generate PDF document from HTML.

MY HTML looks like this

<*p style=“text-align: center; margin: 0in 0in 0.0001pt; font-size: 10pt; font-family: ‘Univers (W1)’, sans-serif; color: black;” align=“center”>SCHEDULE A-BS</*p>
<*p style=“margin: 0in 0in 0.0001pt 0.5in; text-align: justify; font-size: 12pt; font-family: ‘Century Schoolbook’, serif;”>  </*p>
<*p style=“text-align: center; margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: ‘Century Schoolbook’, serif;” align=“center”>BLUE CROSS AND BLUE SHIELD OF FLORIDA, INC.</*p>

REMOVE THE Extra * in

starting tag

when the word document is generated using HtmlFragment it removes the paragraph 2 which is just a blank line.

here is the code we are using

		HtmlFragment htmlFragment = new HtmlFragment(finalString);
	
		
		page.getParagraphs().add(htmlFragment);

our PDF output looks like this

SCHEDULE A-BS
BLUE CROSS AND BLUE SHIELD OF FLORIDA, INC.

but it should be like this

SCHEDULE A-BS

BLUE CROSS AND BLUE SHIELD OF FLORIDA, INC.

please take a look and let us know why the blank line is being removed.

@vijayvikram,

Thanks for contacting support.

I have worked with source file shared by you using Aspose.PDF latest version 20.2 and unable to observe the issue. I have also shared my generated result with you for your kind reference. Can you please check attachment. Please try to use Aspose.PDF latest version on your end and if there is still an issue than please share feedback with us.New Text Document.pdf (32.1 KB)

I tried New Version and still have the same issue

Here is the complete HTML again(please remove * in all the HTML tags.)

<p style=“text-align: center; margin: 0in 0in 0.0001pt; font-size: 10pt; font-family: ‘Univers (W1)’, sans-serif; color: black;” align=“center”><span style=“font-family: ‘times new roman’, times; font-size: 11pt;”><strong>SCHEDULE A-BS</strong></span></p>
<p style=“margin: 0in 0in 0.0001pt 0.5in; font-size: 12pt; font-family: ‘Century Schoolbook’, serif; text-align: justify;”><span style=“font-size: 11pt; font-family: ‘times new roman’, times; color: black;”>&nbsp; </span><*/p>
<p style=“text-align: center; margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: ‘Century Schoolbook’, serif;” align=“center”><span style=“font-family: ‘times new roman’, times; font-size: 11pt;”><strong><span style=“color: black;”>BLUE CROSS AND BLUE SHIELD OF FLORIDA, INC.</span></strong></span></p>

also my complete code

Document pdfDocument = new Document();
// Add a page to pages collection of document
Page page = pdfDocument.getPages().add();
page.getPageInfo().setHeight(792);

		page.getPageInfo().setWidth(612);

		MarginInfo marginInfo = new MarginInfo();

		marginInfo.setLeft(72);

		marginInfo.setRight(72);

		marginInfo.setTop(72);

		marginInfo.setBottom(72);

		page.getPageInfo().setMargin(marginInfo);

		HtmlFragment htmlFragment = new HtmlFragment(finalString);
		
		page.getParagraphs().add(htmlFragment);

ByteArrayOutputStream docOutStream = new ByteArrayOutputStream();

		pdfDocument.save(docOutStream, SaveFormat.Pdf);
		
		byte[] docBytes = docOutStream.toByteArray();

@vijayvikram,

Can you please check output shared by me and share feedback with us if there is any issue. Also please share complete environment details with us.

The Output you shared is what we need. But we are unable to get the file formatted in that way.

Currently this testing is being done on my local machine which is a windows 10 machine.

@vijayvikram,

I like to inform that I am unable to observe the issue with latest version 20.2 on Windows 10 environment by using following sample code.

HtmlLoadOptions htmloptions = new HtmlLoadOptions();
// Load HTML file
Document doc = new Document(path + “NewTextDocument.html”, htmloptions);
// Save HTML file
doc.save(path+“New Text Document.pdf”);

Hi your approach is different that what i am trying to do. can you do using the exact approach and let me know if you can duplicate the issue.

@vijayvikram,

I have shared result generated by your sample code. Can you please check attachment.1223.pdf (31.7 KB)