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

Free Support Forum - aspose.com

Question about trail!

If we handle word files with images in it… with your trial component… it appears to remove images beacause of the red trial stamp, is this correct!?

Or is there another problem here?

This message was posted using Email2Forum by alexey.noskov.

Hi Rodrigo.

Thanks for your request.

Could you attach the document you are having the problem with? Also please describe what you are trying to achieve or provide the code snippet that causes the problem.

I will check the problem on my side.

Thanks,

We are only trying to write a header to the document i sent before… with this code.

StringBuilder sbHeader = new StringBuilder();

sbHeader.Append("<table><tr><td><span style='font-size:8px;'>DokumentId nr: " + dr["FileId"].ToString() + "</span></td><td><span style='font-size:8px;'>DokumentId namn: " + dr["FileNameDOS"].ToString() + "</span></td><td><span style='font-size:8px;'>Skapat av: " + dr["Creator"].ToString() + "</span></td></tr><tr><td><span style='font-size:8px;'>Skapat datum: " + dr["CreatedDate"].ToString() + "</span></td><td><span style='font-size:8px;'>Ändrat av: " + dr["FirstName"].ToString() + " " + dr["LastName"].ToString() + "</span></td><td><span style='font-size:8px;'>Ändrat datum: " + dr["LastChange"].ToString() + "</span></td></tr><tr><td><span style='font-size:8px;'>Version: " + dr["Versions"].ToString() + "</span><td><td></tr></table>");

Document doc = new Document(strFileName);
DocumentBuilder builder = new DocumentBuilder(doc);
Section currentSection = builder.CurrentSection;
currentSection.HeadersFooters.Clear();
Aspose.Words.PageSetup pageSetup = currentSection.PageSetup;
// Specify if we want headers/footers of the first page to be different from other pages.
// You can also use PageSetup.OddAndEvenPagesHeaderFooter property to specify
// different headers/footers for odd and even pages.
pageSetup.DifferentFirstPageHeaderFooter = false;
// — Create header for the first page. —
pageSetup.HeaderDistance = 18;
builder.MoveToHeaderFooter(Aspose.Words.HeaderFooterType.HeaderFirst);
builder.ParagraphFormat.Alignment = Aspose.Words.ParagraphAlignment.Left;
// Set font properties for header text.
builder.Font.Name = "Arial";
builder.Font.Bold = true;
builder.Font.Size = 7;
// Specify header title for the first page.
builder.InsertHtml(sbHeader.ToString());
// — Create header for pages other than first. —
//pageSetup.HeaderDistance = 20;
builder.MoveToHeaderFooter(Aspose.Words.HeaderFooterType.HeaderPrimary);
// Insert absolutely positioned image into the top/left corner of the header.
// Distance from the top/left edges of the page is set to 10 points.
string imageFileName = Server.MapPath("images/logo.jpg"); // MyDir + "Aspose.Words.gif";
builder.InsertImage(imageFileName, RelativeHorizontalPosition.Page, 450, RelativeVerticalPosition.Page, 10, 90, 45, WrapType.Through);
builder.ParagraphFormat.Alignment = Aspose.Words.ParagraphAlignment.Left;
// Specify another header title for other pages.
builder.InsertHtml(sbHeader.ToString());
// — Create footer for pages other than first. —
builder.MoveToHeaderFooter(Aspose.Words.HeaderFooterType.FooterPrimary);
// We use table with two cells to make one part of the text on the line (with page numbering)
// to be aligned left, and the other part of the text (with copyright) to be aligned right.
builder.StartTable();
// Calculate table width as total page width with left and right marins subtracted.
double tableWidth = pageSetup.PageWidth - pageSetup.LeftMargin - pageSetup.RightMargin;
builder.InsertCell();
// Set first cell to 1/3 of the page width.
builder.CellFormat.Width = tableWidth / 3;
// Insert page numbering text here.
// It uses PAGE and NUMPAGES fields to autocalculate current page number and total number of pages.
builder.Write("Sida ");
builder.InsertField("PAGE", "");
builder.Write(" av ");
builder.InsertField("NUMPAGES", "");
// Align this text to the left.
builder.CurrentParagraph.ParagraphFormat.Alignment = Aspose.Words.ParagraphAlignment.Left;
builder.InsertCell();
// Set the second cell to 2/3 of the page width.
builder.CellFormat.Width = tableWidth * 2 / 3;
builder.Write("Infratek");
// Align this text to the right.
builder.CurrentParagraph.ParagraphFormat.Alignment = Aspose.Words.ParagraphAlignment.Right;
builder.EndRow();
builder.EndTable();
builder.MoveToDocumentEnd();
// Make page break to create a second page on which the primary headers/footers will be seen.
//builder.InsertBreak(Aspose.Words.BreakType.PageBreak);
// Make section break to create a third page with different page orientation.
//builder.InsertBreak(Aspose.Words.BreakType.SectionBreakNewPage);
//currentSection.HeadersFooters.Clear();
// Get the new section and its page setup.
currentSection = builder.CurrentSection;
pageSetup = currentSection.PageSetup;
// Set page orientation of the new section to landscape.
//pageSetup.Orientation = Aspose.Words.Orientation.Landscape;
// This section does not need different first page header/footer.
// We need only one title page in the document and the header/footer for this page
// has already been defined in the previous section
pageSetup.DifferentFirstPageHeaderFooter = false;
// This section displays headers/footers from the previous section by default.
// Call currentSection.HeadersFooters.LinkToPrevious(false) to cancel this.
// Page width is different for the new section and therefore we need to set
// a different cell widths for a footer table.
currentSection.HeadersFooters.LinkToPrevious(false);
// If we want to use the already existing header/footer set for this section
// but with some minor modifications then it may be expedient to copy heders/footers
// from the previous section and apply the necessary modifications where we want them.
CopyHeadersFootersFromPreviousSection(currentSection);
// Find the footer that we want to change.
Aspose.Words.HeaderFooter primaryFooter = currentSection.HeadersFooters[Aspose.Words.HeaderFooterType.FooterPrimary];
// Calculate the table width to fit the current page width.
tableWidth = pageSetup.PageWidth - pageSetup.LeftMargin - pageSetup.RightMargin;
Aspose.Words.Tables.Row row = primaryFooter.Tables[0].FirstRow;
row.FirstCell.CellFormat.Width = tableWidth / 3;
row.LastCell.CellFormat.Width = tableWidth * 2 / 3;
// Save the resulting document.
doc.Save(strFileName);

When the doc is saved it has no image starting from page 2 and foward

An update on the issue.

We can see that the objects missing after uploading are not images but some included "figures objects.

Any clues!?

Hi Rodrigo,

Please attach to this thread the document to which you are trying to add the header.

Thanks,

our purchase of this component depends on this answer… and we really would need to know if you will be able to respond us with the result in the nearest hour.

Thank you!

Hi Rodrigo,

I was able to reproduce the issue. I logged this issue in our defect database. You will be notified once it is fixed.

As a quick workaround you can save the document to DOC format and then add a header to document.

Regards,

I did that an got an whole crash on the application with the same code… it seems its not even able to upload my document anymore???

Just saved as 97 - 2003… other docs are working but not this particular one!??

Hi,

You need to save the document you attached to DOC format using MS Word. After that you can add the header using Aspose.Words.

Regards,

That is exactly what i did… in word i saved it as ms word ( 97 - 2003 ) and the tried to upload using a standard .net upload control… but its not even uploading anymore!? Hmmm

ok no worries… was something else.

One last question… when do you think that the issue with the SmartArt will be resolved!?

Hi,

Our developer is investigating this issue. Once he finishes the analysis I will let you know the details.

Regards,

Hi Rodrigo,

This issue most likely will be fixed in the next release of Aspose.Words.

Aspose.Words releases are published every 4-5 weeks.

Regards,

Hello, checking back!

Is this issue updated in the latest release!?

Would be good to know… and in that case where to download

Thank you!

Hi

Thanks for your inquiry. The issue is already resolved in the current codebase. The fix will be included into the next version of Aspose.Words, which comes out in the next couple of days. We will notify you.

Best regards,

The issues you have found earlier (filed as 8596) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.