Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]Highlighted Text/Forms/Links not exported #576

Closed
TheGoderGuy opened this issue Jan 13, 2025 · 3 comments
Closed

[BUG]Highlighted Text/Forms/Links not exported #576

TheGoderGuy opened this issue Jan 13, 2025 · 3 comments

Comments

@TheGoderGuy
Copy link

Description

Any highlighted Elements in docx won't be exported on PDF convert.
Seems like the highlighted text already disappears after template filling just before converting

Expected Behavior

Highlighted text from templates should be exported to pdf

Actual Behavior

Steps to reproduce the behavior:

  1. Add highlight to template
  2. Use code to generate
  3. ???
  4. PDF without highlight

Attachments

`package main

import (
"fmt"
"log"
"os"

cfg "github.com/ardanlabs/conf/v3"
"github.com/unidoc/unioffice/common/license"
"github.com/unidoc/unioffice/document"
"github.com/unidoc/unioffice/document/convert"
pdflicense "github.com/unidoc/unipdf/v3/common/license"

)

type config struct {
UniofficeLicenseKey string conf:"flag:license,env:LICENSE_KEY"
UniofficeCustomerName string conf:"flag:name,env:CUSTOMER_NAME"
UniofficeApiKey string conf:"flag:key,env:API_KEY"
}

func main() {
var conf config
txt, err := cfg.Parse("", &conf)
if err == cfg.ErrHelpWanted {
fmt.Println(txt)
os.Exit(0)
}
if err != nil {
fmt.Println(err)
fmt.Println(txt)
os.Exit(1)
}

switch {
case conf.UniofficeApiKey != "":
	if err := license.SetMeteredKey(conf.UniofficeApiKey); err != nil {
		fmt.Println(err, "set unioffice api key")
		os.Exit(1)
	}
	if err := pdflicense.SetMeteredKey(conf.UniofficeApiKey); err != nil {
		fmt.Println(err, "set unipdf api key")
		os.Exit(1)
	}
case conf.UniofficeLicenseKey != "":
	if conf.UniofficeCustomerName == "" {
		fmt.Println("customer name required for license key")
		os.Exit(1)
	}
	if err := license.SetLicenseKey(conf.UniofficeLicenseKey, conf.UniofficeCustomerName); err != nil {
		fmt.Println(err, "set unioffice license key")
		os.Exit(1)
	}
	if err := pdflicense.SetLicenseKey(conf.UniofficeLicenseKey, conf.UniofficeCustomerName); err != nil {
		fmt.Println(err, "set unipdf license key")
		os.Exit(1)
	}
default:
	fmt.Println("neither api or license key provided")
	os.Exit(1)
}

doc, err := document.Open("crash-test-dummy.docx")
if err != nil {
	log.Fatal(err)
}

defer doc.Close()

// doc has to be copied so the eventually added images of barcodes are also exported to the PDF
renewedDoc, err := doc.Copy()
if err != nil {
	log.Fatal(err)
}

temporaryDocxFile, err := os.CreateTemp(".", "*.docx")
if err != nil {
	log.Fatal(err)
}
defer os.Remove(temporaryDocxFile.Name())
defer temporaryDocxFile.Close()

err = renewedDoc.SaveToFile(temporaryDocxFile.Name())
if err != nil {
	log.Fatal(err)
}
defer renewedDoc.Close()

completed, err := document.Open(temporaryDocxFile.Name())
if err != nil {
	log.Fatal(err)
}
defer completed.Close()

convert.RegisterFontsFromDirectory("ttf")

pdfDoc := convert.ConvertToPdf(completed)
err = pdfDoc.WriteToFile("crash-test-dummy.pdf")
if err != nil {
	log.Fatal(err)
}

}`

unidoc_export.pdf
3rdparty_export.pdf

Attached are a rightly filled pdf and the unidoc pdf.
This bug hits all kinds of things possible in word: Text, Tables, forms like checkboxes, Radio Buttons etc.

Verison:
github.com/unidoc/unioffice v1.39.0
github.com/unidoc/unipdf/v3 v3.65.0

Copy link

Welcome! Thanks for posting your first issue. The way things work here is that while customer issues are prioritized, other issues go into our backlog where they are assessed and fitted into the roadmap when suitable. If you need to get this done, consider buying a license which also enables you to use it in your commercial products. More information can be found on https://unidoc.io/

@3ace
Copy link

3ace commented Jan 13, 2025

Hello @TheGoderGuy ,

The feature you mentioned has been implemented and is expected to be available in our next release, which is anticipated to be released by the end of this month.

In the meantime, it would be greatly appreciated if you could provide us with a DOCX file for testing the feature.

@3ace
Copy link

3ace commented Feb 4, 2025

Hello @TheGoderGuy,

We have released a new UniOffice v2 that should assist in converting highlighted text to PDF.

Link to the release

I am closing this ticket. If you have any further questions, please open a new one.

@3ace 3ace closed this as completed Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants